<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets" >
<ui:composition template="/templates/principal.xhtml" >
<ui:define name="corpo">
<p:growl id="mensagens" globalOnly="true" />
<p:panel header="Cadastro de processo" style="text-align: center; height: 740px; padding: 0px; font-size: 16px" >
<br />
<h:panelGrid columns="2" cellpadding="3" style="text-align: left;" >
    <h:panelGroup>
        <h:form id="cadastroProcesso" prependId="false" >
        <p:fieldset>
            <h:panelGroup>
                <h:selectOneRadio id="pagOuhap" value="#{cadastroProcessoBean.isProcesso}" layout="lineDirection" valueChangeListener="#{cadastroProcessoBean.atualizaNupRadio}" > 
                    <f:selectItem itemLabel="Processo" itemValue="true" />  
                    <f:selectItem itemLabel="Hapvida" itemValue="false" />  
                    <p:ajax event="change" update="uf, pag" /> 
                </h:selectOneRadio>
            </h:panelGroup>
            <h:panelGrid id="panelProHap" columns="4">
                <h:outputLabel value="PAG:" for="pag" />
                <h:inputText id="pag" value="#{cadastroProcessoBean.nupProcHap}" required="true" size="22" requiredMessage="Campo PAG obrigatório!" maxlength="255" validator="validaPagId" style="text-transform: uppercase" disabled="true" >
                    <p:ajax event="blur" update="pagMessage"  /> 
                </h:inputText>
                <h:selectOneMenu id="uf" value="#{cadastroProcessoBean.uf}" valueChangeListener="#{cadastroProcessoBean.atualizaNupPorUf}" disabled="#{cadastroProcessoBean.isProcesso}">
                    <f:selectItems value="#{cadastroProcessoBean.ufs}" var="it" itemValue="#{it.value}" itemLabel="#{it.description}" />
                    <f:ajax execute="@this" render="pag" event="change"  />
                </h:selectOneMenu>
                <h:message id="pagMessage" for="pag" style="color: red; font-size: 11px"/>
            </h:panelGrid>
        </p:fieldset>
        <br/>
        <p:fieldset>
            <h:panelGrid columns="3" cellpadding="3" >
                <h:outputLabel value="PAM:" for="pam" />
                <h:inputText id="pam" value="#{cadastroProcessoBean.processo.pam}" required="true" size="22" requiredMessage="Campo PAM obrigatório!" maxlength="255" validator="validaPamId" style="text-transform: uppercase" >
                    <p:ajax event="blur" update="pamMessage" /> 
                </h:inputText>
                <h:message id="pamMessage" for="pam" style="color: red; font-size: 11px"/> 
                <h:outputLabel value="Unidade do PAM:" for="unidade" />
                <h:selectOneMenu  id="unidade" value="#{cadastroProcessoBean.processo.unidadeSolicitante}" valueChangeListener="#{setorBean.selecionaSetorPorOM}" required="true" requiredMessage="Campo Unidade obrigatório!" validator="validaOMId">
                    <f:selectItem itemValue="-1" itemLabel="Selecione"  />
                    <f:selectItems value="#{unidadeMilitarBean.listarTipos}" var="it" itemValue="#{it.value}" itemLabel="#{it.key}" />
                    <f:ajax execute="@this" render="setorP" event="change"  />
                    <p:ajax event="blur" update="unidadeMessage"  />
                </h:selectOneMenu>
                <h:message id="unidadeMessage" for="unidade" style="color: red; font-size: 11px" />
                <h:outputLabel value="Setor do PAM: " for="setorP" />
                <h:selectOneMenu id="setorP" value="#{cadastroProcessoBean.processo.setorSolicitante}" immediate="true" required="true" requiredMessage="Campo Setor obrigatório!"  validator="validaSetorId" >
                    <f:selectItem itemValue="-1" itemLabel="Selecione"  />
                    <f:selectItems value="#{setorBean.listarSetorPorOm}" var="item" itemValue="#{item.idsetor}" itemLabel="#{item.descricaoSetor}" />
                    <p:ajax event="blur" update="setorMessage"  />
                </h:selectOneMenu>
                <h:message id="setorMessage" for="setorP" style="color: red; font-size: 11px" /> 
                <h:outputLabel value="Data PAG:" for="dataPagC" />
                <p:calendar id="dataPagC" value="#{cadastroProcessoBean.processo.dataProcesso}"  size="15" required="true" showOn="button" validatorMessage="O formato deve ser dd/mm/aaaa" requiredMessage="Campo Data PAG obrigatório!" readOnlyInputText="true" locale="pt,BR" timeZone="America/Sao_Paulo" pattern="dd/MM/yyyy" />
                <h:message id="dataPagCMessage" for="dataPagC" style="color: red; font-size: 11px"/>
                <h:outputLabel value="Arquivo (Somente PDF):" for="arquivo"/>
                <h:inputText id="arquivo" value="#{cadastroProcessoBean.nomeArquivoSelecionado}" disabled="true" size="45" />
                <p:fileUpload label="Selecione..." sizeLimit="" auto="true" width="120" allowTypes="*.pdf" multiple="false" description="pdf" fileUploadListener="#{cadastroProcessoBean.fileUploadAction}" wmode="advanced" update="arquivo"  />
                <h:outputLabel value="Objeto:" for="ob1" />
            </h:panelGrid>
            <h:panelGroup>
                <p:inputTextarea id="ob1" value="#{cadastroProcessoBean.processo.objeto}" required="true" cols="60" rows="10" autoResize="false" requiredMessage="Campo Objeto obrigatório!" style="font-size: 11px;" >
                    <p:ajax event="blur" update="objetoMessage"  />
                </p:inputTextarea>
                <h:message id="objetoMessage" for="ob1" style="color: red; font-size: 11px"/> 
            </h:panelGroup>
            <br />
            <br />
            <h:panelGroup>
                <p:commandButton action="#{cadastroProcessoBean.salvar}" value="Salvar" update="cadastroProcesso, mensagens" style="font-size: 11px" image="ui-icon ui-icon-disk" />
            </h:panelGroup>
        </p:fieldset>
        </h:form>
    </h:panelGroup>
    <h:panelGroup>
        <p:fieldset legend="UF" style="width: 250px;">
            <p:dataList value="#{unidadesFederativasBean.ufso}" var="ufs" type="ordered" itemType="square" >  
                <h:outputText value="#{ufs}" />
            </p:dataList>
        </p:fieldset>
    </h:panelGroup>
        
</h:panelGrid>

</p:panel>
</ui:define>
</ui:composition>
</html>